package com.canxi.earn.app;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaIgnore;
import cn.hutool.core.util.ObjectUtil;
import com.canxi.common.annotation.Log;
import com.canxi.common.annotation.RepeatSubmit;
import com.canxi.common.core.controller.BaseController;
import com.canxi.common.core.domain.PageQuery;
import com.canxi.common.core.domain.R;
import com.canxi.common.core.domain.entity.SysDictData;
import com.canxi.common.core.page.TableDataInfo;
import com.canxi.common.enums.BusinessType;
import com.canxi.common.utils.poi.ExcelUtil;
import com.canxi.system.service.ISysDictDataService;
import com.canxi.system.service.ISysDictTypeService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

/**
 * 数据字典信息
 *
 * @author Lion Li
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/app/system/dict/data")
public class CxAppDictDataController extends BaseController {

    private final ISysDictDataService dictDataService;
    private final ISysDictTypeService dictTypeService;

    /**
     * 查询字典数据列表
     */


    /**
     * 根据字典类型查询字典数据信息
     *
     * @param dictType 字典类型
     */
    @SaIgnore
    @RepeatSubmit()
    @GetMapping(value = "/type/{dictType}")
    public R<List<SysDictData>> dictType(@PathVariable String dictType) {
        List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
        if (ObjectUtil.isNull(data)) {
            data = new ArrayList<>();
        }
        return R.ok(data);
    }
}
